home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / program / 441 / dlibs12 / rand.c < prev    next >
C/C++ Source or Header  |  1990-11-23  |  488b  |  27 lines

  1. #include <osbind.h>
  2. #include <stdio.h>
  3.  
  4. rand()
  5.     {
  6.     return((Random() >> 3) & RAND_MAX);
  7.     }
  8.  
  9. /*
  10.  *    In environments where the operating system doesn't provide
  11.  *    a random number generator, the following code may be useful.
  12.  *
  13.  *    static unsigned long _seed = 1;
  14.  *
  15.  *    int rand()
  16.  *        {
  17.  *        _seed = (_seed * 1103515245) + 12345;
  18.  *        return((unsigned int) ((next / 65536) % 32768));
  19.  *        }
  20.  *
  21.  *    void srand(seed)
  22.  *        unsigned int seed;
  23.  *        {
  24.  *        _seed = seed;
  25.  *        }
  26.  */
  27.